home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / sound / guitarchord / gchordcomm.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  4KB  |  151 lines

  1. /* GChordcomm.rexx */
  2.  
  3.  
  4. options results
  5. address music
  6. parse arg comm
  7.  
  8.  
  9. MUIA_TWFmultiLED_Colour   =    0xfebd0001
  10. MUIV_TWFmultiLED_Colour_Off      =   0
  11. MUIV_TWFmultiLED_Colour_On       =   1
  12. MUIV_TWFmultiLED_Colour_Ok       =   2
  13. MUIV_TWFmultiLED_Colour_Error    =   4
  14. MUIV_TWFmultiLED_Colour_Panic    =   5
  15.  
  16.  
  17. address command 'copy' "ChordDbase.txt" "ram:Chords" 'quiet'
  18.  
  19. select
  20. when comm = 'CHORD' then do
  21.     do k = 1 to 3
  22.         text id TG||k label ""
  23.         text id TN||k label ""
  24.     end
  25.     do y = 0 to 5
  26.         do x = 1 to 6
  27.             object class "TWFmultiLED.mcc" id L||y||x ATTRS MUIA_TWFmultiLED_Colour MUIV_TWFmultiLED_Colour_Off
  28.             object class "TWFmultiLED.mcc" id M||y||x ATTRS MUIA_TWFmultiLED_Colour MUIV_TWFmultiLED_Colour_Off
  29.             object class "TWFmultiLED.mcc" id N||y||x ATTRS MUIA_TWFmultiLED_Colour MUIV_TWFmultiLED_Colour_Off
  30.         end
  31.     end
  32.     string id S1
  33.     chord = result
  34.     call CONVERT
  35.     address command 'search' "ram:chords" '>' "ram:found" chord  'nonum'
  36.  
  37.     if open('ch',"ram:found",'r') then do i = 1 to 3
  38.         line.i = readln('ch')
  39.         if line.1 = "" then call stop
  40.         view id V1 string "Found!\nRed = Don't play string.\nGreen = Play string open.\nYellow = Fret string as shown.\nBasefret = lowest fret of the chord fingering.\nWait until this text changes before inputing another chord!"
  41.         if line.i = "" then leave
  42.         parse var line.i chord.i '[' fret.i ']'
  43.     end
  44.  
  45.     call close('ch')
  46.  
  47.     shft = 0
  48.     do k = 1 to i-1
  49.         fret = fret.k
  50.         call notefind
  51.         call base
  52.         if basefret > 1 then shft = basefret-1
  53.         text id TG||k label basefret
  54.         if k = 1 then ide = "L"
  55.         if k = 2 then ide = "M"
  56.         if k = 3 then ide = "N"
  57.         ch = ""
  58.  
  59.         do  j = 1 to 6
  60.             note = word(fret,j)
  61.             if basefret > 1 then if (upper(note) ~= "X" & upper(note) ~= "0") then note = note-shft
  62.             if upper(note) ~= "X" then ident = ide||note||j
  63.             if upper(note) = "X" then ident = ide||"0"||j
  64.             if upper(note) = "0" then object class "TWFmultiLED.mcc" id ident ATTRS MUIA_TWFmultiLED_Colour MUIV_TWFmultiLED_Colour_OK
  65.             if upper(note) = "X" then object class "TWFmultiLED.mcc" id ident ATTRS MUIA_TWFmultiLED_Colour MUIV_TWFmultiLED_Colour_Panic
  66.             if upper(note) > 0 & upper(note) < 15  then object class "TWFmultiLED.mcc" id ident ATTRS MUIA_TWFmultiLED_Colour MUIV_TWFmultiLED_Colour_Error
  67.             ch = ch note
  68.         end
  69.  
  70.     end
  71.     address command 'delete' "ram:found" 'quiet'
  72.     address command 'wait 5'
  73.     view id V1 string "Type the name of the chord you want to see in the 'search chord' input field. Up to 3 fingerings will be shown, depending on the chord."
  74. end
  75. otherwise nop
  76. end
  77. exit
  78.  
  79. /* ******************************************************** */
  80.  
  81. BASE:
  82. max = 0 ; min = 15
  83. do h = 1 to 6
  84.     if upper(word(fret,h)) = upper("x") then iterate
  85.     if word(fret,h) = "0" then do
  86.         min2 = 0
  87.         iterate
  88.     end
  89.     if word(fret,h) > max then max = word(fret,h)
  90.     if word(fret,h) < min then min = word(fret,h)
  91. end
  92. if max <= 5 then basefret = 1
  93. if max > 5 then basefret = min
  94. return
  95.  
  96. NOTEFIND:
  97. s.1 = "E F F# G Ab A Bb B C C# D Eb E F F#"
  98. s.2 = "A Bb B C C# D Eb E F F# G Ab A Bb B"
  99. s.3 = "D Eb E F F# G Ab A Bb B C C# D Eb E"
  100. s.4 = "G Ab A Bb B C C# D Eb E F F# G Ab A"
  101. s.5 = "B C C# D Eb E F F# G Ab A Bb B C C#"
  102. s.6 = "E F F# G Ab A Bb B C C# D Eb E F F#"
  103.  
  104. nots = ""
  105. do j = 1 to 6
  106.     if upper(word(fret,j)) = "X" then not.j = "x"
  107.     if upper(word(fret,j)) ~= "X" then do
  108.         wd = word(fret,j)
  109.         not.j = word(s.j,wd+1)
  110.     end
  111.     nots = nots not.j
  112. end
  113. text id 'TN'||k label "\033c"||nots
  114. return
  115.  
  116.  
  117. CONVERT:
  118. Keys = "C D E F G A B"
  119. chord = upper(chord)
  120. l = left(chord,1) ; l2 = substr(chord,2,1)
  121. if (l2 = "#" & l ~= "E" & l ~= "B") | (l2 = "B" & l ~= "C" & l ~= "F")
  122. then parse var chord key 3 rest
  123. else parse var chord key 2 rest
  124.  
  125. s = upper(substr(key,2,1)) ; z = upper(left(key,1))
  126. if length(key) = 2 then do
  127.     if s = "B" then do
  128.         mark = find(keys,z) - 1
  129.         key = word(keys,mark)||"#"
  130.     end
  131. end
  132.  
  133. if rest = "DIM" then rest = "dim7"
  134. if rest = "" then rest = "maj"
  135. if rest = "7" then rest = "dom7"
  136. if rest = "9" then rest = "dom9"
  137. if rest = "SUS" then rest = "sus4"
  138. if rest = "M" then rest = "min"
  139. if rest = "#" then rest = "aug"
  140. if rest = "B" then rest = "-"
  141.  
  142. chord = key||rest
  143. return
  144.  
  145. STOP:
  146. call close('ch')
  147. address command 'delete' "ram:found" 'quiet'
  148. View id V1 string "The requested chord doesn't seem to be available. You can try and search the same chord with a different designation."
  149. exit
  150. return
  151.